//
//  YHModuleOneViewController_1.m
//  YHRouter_Example
//
//  Created by 98du on 2021/11/26.
//  Copyright © 2021 林宁宁. All rights reserved.
//

#import "YHModuleOneViewController_1.h"
#import "YHModuleOneService.h"

@import YHRouter;

@interface YHModuleOneViewController_1 ()

@end

@implementation YHModuleOneViewController_1

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.title = @"push";
    
    YHOptionTableViewItem * item;
    
    item = YHOptionTableItemInitTitle(@"push - 控制器名字", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_pushKey:@"YHModuleOneViewController_2"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - 控制器定义的key 1", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_pushKey:@"oneDetail"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - 控制器定义的key 2", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_pushKey:@"1001"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - 控制器定义的key 3", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_pushKey:kYHModuleOneViewController_2];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"present - 控制器定义的key 1", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_presentKey:kYHModuleOneViewController_2];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"present - 控制器定义的key 2", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_presentKey:@"oneDetail"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - URL: router://oneDetail?id=1001&type=22", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_openURL:@"router://oneDetail?id=1001&type=22"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - URL: router://twoDetail?type=22 ", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_openURL:@"router://twoDetail?type=22"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - URL: other://other?id=1001&type=22", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_openURL:@"other://other?id=1001&type=22"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - Link: https://host?page=helpCenter", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_openUniversalLink:@"https://host?page=helpCenter"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - Link: https://host?page=oneDetail", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_openUniversalLink:@"https://host?page=oneDetail"];
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - Bifrost 1", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_handleKey:kYHModuleOneViewController_2].yh_push();
    }];
    [self addOptionItem:item];
    
    item = YHOptionTableItemInitTitle(@"push - Bifrost 2", YES, YES);
    [item setCellClickBlock:^(NSIndexPath * _Nonnull indexPath, YHOptionTableViewItem * _Nonnull passItem) {
        [YHRouter yh_handleKey:kYHModuleOneViewController_2 params:@{@"type":@(1)} callBack:^(YHRouterParam * _Nullable passResult) {
            
        }];
    }];
    [self addOptionItem:item];
    
    [self reloadContentView];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
